<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 7.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.ico">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha256-wiz7ZSCn/btzhjKDQBms9Hx4sSeUYsDrTLg7roPstac=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.css" integrity="sha256-6cQIC71/iBIYXFK+0RHAvwmjwWzkWd+r7v/BX3/vZDc=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/themes/green/pace-theme-minimal.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/pace.min.js" integrity="sha256-gqd7YTjg/BtfqWSwsJOvndl0Bxc8gFImLEkXQT8+qj0=" crossorigin="anonymous"></script>

<script class="next-config" data-name="main" type="application/json">{"hostname":"sumumm.github.io","root":"/","images":"/images","scheme":"Gemini","darkmode":false,"version":"8.19.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":true,"style":"mac"},"fold":{"enable":true,"height":300},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":true,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="本文主要是BOA服务器移植的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:type" content="article">
<meta property="og:title" content="LV11-01-BOA服务器-01-移植过程">
<meta property="og:url" content="https://sumumm.github.io/post/1d9989a.html">
<meta property="og:site_name" content="苏木">
<meta property="og:description" content="本文主要是BOA服务器移植的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV11-%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%93/LV11-01-BOA%E6%9C%8D%E5%8A%A1%E5%99%A8-01-%E7%A7%BB%E6%A4%8D%E8%BF%87%E7%A8%8B/img/image-20220921081532905.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV11-%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%93/LV11-01-BOA%E6%9C%8D%E5%8A%A1%E5%99%A8-01-%E7%A7%BB%E6%A4%8D%E8%BF%87%E7%A8%8B/img/image-20220905065851391.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV11-%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%93/LV11-01-BOA%E6%9C%8D%E5%8A%A1%E5%99%A8-01-%E7%A7%BB%E6%A4%8D%E8%BF%87%E7%A8%8B/img/image-20220905101822394.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV11-%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%93/LV11-01-BOA%E6%9C%8D%E5%8A%A1%E5%99%A8-01-%E7%A7%BB%E6%A4%8D%E8%BF%87%E7%A8%8B/img/image-20220905101918395.png">
<meta property="article:published_time" content="2023-07-08T11:17:36.000Z">
<meta property="article:modified_time" content="2025-06-13T16:25:57.005Z">
<meta property="article:author" content="苏木">
<meta property="article:tag" content="LV11-第三方库">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV11-%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%93/LV11-01-BOA%E6%9C%8D%E5%8A%A1%E5%99%A8-01-%E7%A7%BB%E6%A4%8D%E8%BF%87%E7%A8%8B/img/image-20220921081532905.png">


<link rel="canonical" href="https://sumumm.github.io/post/1d9989a.html">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"https://sumumm.github.io/post/1d9989a.html","path":"post/1d9989a.html","title":"LV11-01-BOA服务器-01-移植过程"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>LV11-01-BOA服务器-01-移植过程 | 苏木</title>
  








    <script src="/js/browser_tools_disable.js"></script>

  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<!-- hexo injector head_end start --><link rel="stylesheet" href="https://unpkg.com/hexo-next-tags-plus@latest/lib/tag_plus.css" media="defer" onload="this.media='all'"><!-- hexo injector head_end end --></head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">苏木</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">我的学习之路</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>苏木的家</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类页<span class="badge">42</span></a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档页<span class="badge">673</span></a></li><li class="menu-item menu-item-flink"><a href="/flink/" rel="section"><i class="fa fa-link fa-fw"></i>友人帐</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于我</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%80%E3%80%81-BOA-%E7%AE%80%E4%BB%8B"><span class="nav-text">一、 BOA 简介</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%8C%E3%80%81%E6%96%87%E4%BB%B6%E5%87%86%E5%A4%87"><span class="nav-text">二、文件准备</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-BOA-%E6%BA%90%E7%A0%81"><span class="nav-text">1. BOA 源码</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-1-%E6%BA%90%E7%A0%81%E8%8E%B7%E5%8F%96%E9%80%94%E5%BE%84"><span class="nav-text">1.1 源码获取途径</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-2-%E8%8E%B7%E5%8F%96%E6%BA%90%E7%A0%81%E6%96%87%E4%BB%B6"><span class="nav-text">1.2 获取源码文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-3-%E6%8B%B7%E8%B4%9D%E8%A7%A3%E5%8E%8B"><span class="nav-text">1.3 拷贝解压</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%89%E3%80%81-BOA-%E7%A7%BB%E6%A4%8D%E5%88%B0-Ubuntu"><span class="nav-text">三、 BOA 移植到 Ubuntu </span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E9%85%8D%E7%BD%AE%E6%BA%90%E7%A0%81"><span class="nav-text">1. 配置源码</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E6%BA%90%E7%A0%81%E4%BF%AE%E6%94%B9"><span class="nav-text">2. 源码修改</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#2-1-%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%A0%B9%E7%9B%AE%E5%BD%95"><span class="nav-text">2.1 服务器根目录</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-2-boa-c"><span class="nav-text">2.2 boa.c </span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-3-log-c"><span class="nav-text">2.3 log.c </span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E7%BC%96%E8%AF%91%E6%BA%90%E7%A0%81"><span class="nav-text">3. 编译源码</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#3-1-%E7%BC%96%E8%AF%91%E5%91%BD%E4%BB%A4"><span class="nav-text">3.1 编译命令</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-2-%E9%97%AE%E9%A2%98%E4%B8%80"><span class="nav-text">3.2 问题一</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-3-%E9%97%AE%E9%A2%98%E4%BA%8C"><span class="nav-text">3.3 问题二</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-4-%E9%97%AE%E9%A2%98%E4%B8%89"><span class="nav-text">3.4 问题三</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-%E5%AE%89%E8%A3%85-BOA"><span class="nav-text">4. 安装 BOA </span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#4-1-%E5%88%9B%E5%BB%BA%E7%9B%B8%E5%85%B3%E7%9B%AE%E5%BD%95"><span class="nav-text">4.1 创建相关目录</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-2-%E5%A4%8D%E5%88%B6%E7%9B%B8%E5%85%B3%E6%96%87%E4%BB%B6"><span class="nav-text">4.2 复制相关文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-3-%E6%96%87%E4%BB%B6%E2%80%9C%E7%98%A6%E8%BA%AB%E2%80%9D"><span class="nav-text">4.3 文件“瘦身”</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#5-%E4%BF%AE%E6%94%B9%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6"><span class="nav-text">5. 修改配置文件</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#5-1-%E4%BF%AE%E6%94%B9%E5%86%85%E5%AE%B9"><span class="nav-text">5.1 修改内容</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#5-1-1-Port"><span class="nav-text">5.1.1 Port </span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#5-1-2-User-%E5%92%8C-Group"><span class="nav-text">5.1.2 User 和 Group </span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#5-1-3-ErrorLog-%E5%92%8C-AccessLog"><span class="nav-text">5.1.3 ErrorLog 和 AccessLog </span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#5-1-4-DocumentRoot"><span class="nav-text">5.1.4 DocumentRoot </span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#5-1-5-DirectoryIndex"><span class="nav-text">5.1.5 DirectoryIndex </span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#5-1-6-DirectoryMaker"><span class="nav-text">5.1.6 DirectoryMaker </span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#5-1-7-MimeTypes"><span class="nav-text">5.1.7 MimeTypes </span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#5-1-8-CGIPath"><span class="nav-text">5.1.8 CGIPath </span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#5-1-9-ScriptAlias"><span class="nav-text">5.1.9 ScriptAlias </span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5-2-%E6%9C%80%E7%BB%88%E6%96%87%E4%BB%B6%E5%86%85%E5%AE%B9"><span class="nav-text">5.2 最终文件内容</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#6-%E6%B5%8B%E8%AF%95%E6%96%87%E4%BB%B6%E6%B7%BB%E5%8A%A0"><span class="nav-text">6. 测试文件添加</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#6-1-index-html"><span class="nav-text">6.1 index.html </span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6-2-image-jpg"><span class="nav-text">6.2 image.jpg </span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6-3-test-c"><span class="nav-text">6.3 test.c </span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6-4-access-log-%E4%B8%8E-error-log"><span class="nav-text">6.4 access_log 与 error_log </span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#7-%E6%96%87%E4%BB%B6%E7%BB%84%E6%88%90"><span class="nav-text">7. 文件组成</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#8-%E6%95%88%E6%9E%9C%E6%B5%8B%E8%AF%95"><span class="nav-text">8. 效果测试</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#8-1-%E5%90%AF%E5%8A%A8-boa"><span class="nav-text">8.1 启动 boa </span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#8-2-%E6%9C%AC%E5%9C%B0%E6%B5%8B%E8%AF%95"><span class="nav-text">8.2 本地测试</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%9B%9B%E3%80%81-BOA-%E7%A7%BB%E6%A4%8D%E5%88%B0%E5%BC%80%E5%8F%91%E6%9D%BF"><span class="nav-text">四、 BOA 移植到开发板</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E7%A7%BB%E6%A4%8D%E8%BF%87%E7%A8%8B"><span class="nav-text">1. 移植过程</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E5%90%AF%E5%8A%A8%E9%97%AE%E9%A2%98"><span class="nav-text">2. 启动问题</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#2-1-%E9%97%AE%E9%A2%98%E4%B8%80"><span class="nav-text">2.1 问题一</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-2-%E9%97%AE%E9%A2%98%E4%BA%8C"><span class="nav-text">2.2 问题二</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E4%B8%BB%E6%9C%BA%E8%AE%BF%E9%97%AE"><span class="nav-text">3. 主机访问</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%94%E3%80%81-boa-conf-%E6%96%87%E4%BB%B6%E8%AF%A6%E8%A7%A3"><span class="nav-text">五、 boa.conf 文件详解</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-Port"><span class="nav-text">1. Port </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-User"><span class="nav-text">2. User </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-Group"><span class="nav-text">3. Group </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-UseLocaltime"><span class="nav-text">4. UseLocaltime </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#5-VerboseCGILogs"><span class="nav-text">5. VerboseCGILogs </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#6-ServerName"><span class="nav-text">6. ServerName </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#7-VirtualHost"><span class="nav-text">7. VirtualHost </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#8-DocumentRoot"><span class="nav-text">8. DocumentRoot </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#9-UserDir"><span class="nav-text">9. UserDir </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#10-DirectoryIndex"><span class="nav-text">10. DirectoryIndex </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#11-DirectoryMaker"><span class="nav-text">11. DirectoryMaker </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#12-DirectoryCache"><span class="nav-text">12. DirectoryCache </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#13-KeepAliveMax"><span class="nav-text">13. KeepAliveMax </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#14-KeepAliveTimeout"><span class="nav-text">14. KeepAliveTimeout </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#15-MimeTypes"><span class="nav-text">15. MimeTypes </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#16-DefaultType"><span class="nav-text">16. DefaultType </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#17-CGIPath"><span class="nav-text">17. CGIPath </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#18-AddType"><span class="nav-text">18. AddType </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#19-Redirect"><span class="nav-text">19. Redirect </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#20-Alias"><span class="nav-text">20. Alias </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#21-ScriptAlias"><span class="nav-text">21. ScriptAlias </span></a></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="苏木"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">苏木</p>
  <div class="site-description" itemprop="description">莫道桑榆晚，为霞尚满天</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">673</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">42</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">43</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://github.com/sumumm" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;sumumm" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://sumumm.github.io/post/1d9989a.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="苏木">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏木">
      <meta itemprop="description" content="莫道桑榆晚，为霞尚满天">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="LV11-01-BOA服务器-01-移植过程 | 苏木">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          LV11-01-BOA服务器-01-移植过程
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2023-07-08 19:17:36" itemprop="dateCreated datePublished" datetime="2023-07-08T19:17:36+08:00">2023-07-08</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/" itemprop="url" rel="index"><span itemprop="name">嵌入式开发</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/" itemprop="url" rel="index"><span itemprop="name">01HQ课程体系</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV11-%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%93/" itemprop="url" rel="index"><span itemprop="name">LV11-第三方库</span></a>
        </span>
    </span>

  
    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>6.7k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>24 分钟</span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><p>本文主要是BOA服务器移植的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。</p>
<span id="more"></span>

<!-- Photo: https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV11-%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%93/LV11-01-BOA%E6%9C%8D%E5%8A%A1%E5%99%A8-01-%E7%A7%BB%E6%A4%8D%E8%BF%87%E7%A8%8B/img/ -->

<details class="folding-tag" blue><summary> 点击查看使用工具及版本 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center" width=150px>Windows</td>        <td align="left">windows11</td>    </tr>    <tr>        <td align="center">Ubuntu</td>        <td align="left">Ubuntu16.04的64位版本</td>      </tr>    <tr>        <td align="center">VMware® Workstation 16 Pro</td>        <td align="left">16.2.3 build-19376536</td>      </tr>    <tr>        <td align="center">SecureCRT</td>        <td align="left">Version 8.7.2 (x64 build 2214)   -   正式版-2020年5月14日</td>      </tr>    <tr>        <td align="center" width=150>Linux开发板</td>        <td align="left">华清远见 底板: FS4412_DEV_V5 核心板: FS4412 V2</td>      </tr>    <tr>        <td align="center" width=150>u-boot</td>        <td align="left">2013.01</td>      </tr>    <tr>        <td align="center" width=150>linux内核</td>        <td align="left">linuz-3.14</td>      </tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看本文参考资料 </summary>
              <div class='content'>
              <table>    <tr><td align="center">参考方向</td><td align="center">参考原文</td></tr>    <tr><td align="left">华清远见课程</td><td align="left">华清远见课程</td></tr>    <tr><td align="left">驱动开发指南</td><td align="left"><a href="http://47.111.11.73/docs/boards/arm-linux/zdyz-i.mx6ull.html#i-mx6ull-linux" target="_blank">i.MX6ULL Linux阿尔法开发板资料 <i class="fa fa-external-link-alt"></i> </a></td></tr>    <tr><td align="left">BOA官网</td><td align="left"><a href="http://www.boa.org/" target="_blank">Boa Webserver <i class="fa fa-external-link-alt"></i> </a></td></tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看相关文件下载 </summary>
              <div class='content'>
              <table>    <tr><td align="center">文件</td><td align="center">下载链接</td></tr>    <tr><td align="left">---</td><td align="left"><a href="" target="_blank">--- <i class="fa fa-external-link-alt"></i> </a></td></tr></table>
              </div>
            </details>

<h1 id="一、-BOA-简介"><a href="#一、-BOA-简介" class="headerlink" title="一、 BOA 简介"></a><font size=3>一、 BOA 简介</font></h1><p>BOA是一个小型高效的Web服务器，它可以运行于 unix 或 linux 下，支持CGI （ CGI 只是一个进程，用来提供接口，完成HTML与C语言之间的数据通信），它也是一个适合于嵌入式系统的单任务 http 服务器。</p>
<p>其可执行代码只有大约 60KB 左右，  BOA 只能依次完成用户的请求，而不会 fork 出新的进程来处理并发连接请求。BOA 的主要设计目标是速度和安全性。安全性在“不能被恶意用户破坏”的意义上，不是“细粒度访问控制和加密通信”。</p>
<p>BOA的特点：可靠性和可移植性，他并不作为一个功能强大的服务器，它使用 GNU&#x2F;Linux作为开发平台。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV11-%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%93/LV11-01-BOA%E6%9C%8D%E5%8A%A1%E5%99%A8-01-%E7%A7%BB%E6%A4%8D%E8%BF%87%E7%A8%8B/img/image-20220921081532905.png" alt="image-20220921081532905" style="zoom:50%;" />

<p>如上图所示，A9平台作为一个客户端，网页也作为一个客户端，他们使用的编程语言是不一样的，A9平台使用的是C语言，web网页端使用的是HTML语言，我们的数据要想从A9到 web，或者从web到A9的话，他们之间需要一个“桥梁”，通过这个桥梁打通两种语言之间的数据通信，这个桥梁就是CGI，这是一个进程，它提供了C语言和HTML之间的接口，可以实现两者之间数据的交互。</p>
<p>但是有了沟通的桥梁还不够，CGI和HTML是不同的文件吗，他们怎么知道对方在哪里呢？而且我们要将数据发送出去，又要接收数据，他们怎么知道数据是发给谁的呢？怎么知道数据来自哪里呢？这些问题都是依赖于BOA服务器，BOA服务器可以完成数据的封装和转发，可以让HTML找到CGI文件在哪，CGI文件也可以找到HTML文件在哪，这样就保证了他们之间的通信，这样我们便实现了web网页与A9平台的一个通信了。</p>
<h1 id="二、文件准备"><a href="#二、文件准备" class="headerlink" title="二、文件准备"></a><font size=3>二、文件准备</font></h1><h2 id="1-BOA-源码"><a href="#1-BOA-源码" class="headerlink" title="1. BOA 源码"></a><font size=3>1. BOA 源码</font></h2><h3 id="1-1-源码获取途径"><a href="#1-1-源码获取途径" class="headerlink" title="1.1 源码获取途径"></a><font size=3>1.1 源码获取途径</font></h3><p>关于 BOA 的官方源码我们可以从这里获取：<a target="_blank" rel="noopener" href="http://www.boa.org/">Boa Webserver——Latest Released Version (0.94.13) <i class="fa fa-external-link-alt"></i> </a></p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV11-%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%93/LV11-01-BOA%E6%9C%8D%E5%8A%A1%E5%99%A8-01-%E7%A7%BB%E6%A4%8D%E8%BF%87%E7%A8%8B/img/image-20220905065851391.png" alt="image-20220905065851391" style="zoom: 33%;" />

<h3 id="1-2-获取源码文件"><a href="#1-2-获取源码文件" class="headerlink" title="1.2 获取源码文件"></a><font size=3>1.2 获取源码文件</font></h3><p>我下载的是 boa-0.94.13.tar.gz 这个压缩包并将其存放于 ubuntu 下的共享文件夹下，路径为：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">/mnt/hgfs/Sharedfiles/</span><br></pre></td></tr></table></figure>

<h3 id="1-3-拷贝解压"><a href="#1-3-拷贝解压" class="headerlink" title="1.3 拷贝解压"></a><font size=3>1.3 拷贝解压</font></h3><p>然后我们可以将这个源码文件拷贝解压到 ubuntu 中，方便后边编译，我们可以在终端执行以下命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">cp /mnt/hgfs/Sharedfiles/boa-0.94.13.tar.gz ~/6temp/    # 拷贝压缩包</span><br><span class="line">cd ~/6temp/</span><br><span class="line">tar -xvf boa-0.94.13.tar.gz                            # 解压</span><br></pre></td></tr></table></figure>

<p>然后我们可以得到下边这些文件（通过 ls 命令查看）：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">boa.conf   contrib  docs      extras       README</span><br><span class="line">ChangeLog  CREDITS  examples  Gnu_License  src</span><br></pre></td></tr></table></figure>

<h1 id="三、-BOA-移植到-Ubuntu"><a href="#三、-BOA-移植到-Ubuntu" class="headerlink" title="三、 BOA 移植到 Ubuntu "></a><font size=3>三、 BOA 移植到 Ubuntu </font></h1><h2 id="1-配置源码"><a href="#1-配置源码" class="headerlink" title="1. 配置源码"></a><font size=3>1. 配置源码</font></h2><p>我们进入 boa 源码中的 src 目录：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cd ~/6temp/cd ~/6temp/boa-0.94.13/src/</span><br></pre></td></tr></table></figure>

<p>然后执行以下命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">./configure</span><br></pre></td></tr></table></figure>

<p>之后便会根据 configure.in 文件进行一系列的配置，生成 config.status 、 configure ，和 Makefile 文件，后续我们才能进行源码编译，如果无法执行这个命令，可以修改一下文件权限：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">suod chmod 755 configure</span><br></pre></td></tr></table></figure>

<h2 id="2-源码修改"><a href="#2-源码修改" class="headerlink" title="2. 源码修改"></a><font size=3>2. 源码修改</font></h2><p>这部分是移植完，启动 boa 服务器可能遇到的问题。</p>
<h3 id="2-1-服务器根目录"><a href="#2-1-服务器根目录" class="headerlink" title="2.1 服务器根目录"></a><font size=3>2.1 服务器根目录</font></h3><p>我们在后边安装完成后，启动 boa 服务器时，会遇到这样一个问题：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Could not chdir to &quot;/etc/boa&quot;: aborting</span><br></pre></td></tr></table></figure>

<p>我们打开 boa 服务器源码中 src 目录下的 defines.h 文件：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vim ~/6temp/boa-0.94.13/src/defines.h</span><br></pre></td></tr></table></figure>

<p>我们找到下边的语句：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">define</span> SERVER_ROOT <span class="string">&quot;/etc/boa&quot;</span></span></span><br></pre></td></tr></table></figure>

<p>将其修改为：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">define</span> SERVER_ROOT <span class="string">&quot;/home/hk/6temp/boa&quot;</span></span></span><br></pre></td></tr></table></figure>

<p>然后保存退出，这样 boa 程序启动时会在 &#x2F;home&#x2F;hk&#x2F;6temp&#x2F;boa 目录下寻找 boa.conf 配置文件，并且将 &#x2F;home&#x2F;hk&#x2F;6temp&#x2F;boa 目录作为服务器的根目录。</p>
<h3 id="2-2-boa-c"><a href="#2-2-boa-c" class="headerlink" title="2.2 boa.c "></a><font size=3>2.2 boa.c </font></h3><p> boa 启动时会可能出现：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">boa.c:226 - icky linux kernel bug!: No suchfile or directory</span><br></pre></td></tr></table></figure>

<p>我们使用 vim 打开 boa.c 这个文件：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">文件路径：boa-0.94.13/src/boa.c</span></span><br><span class="line">vim ~/6temp/boa-0.94.13/src/boa.c +225     # 这个版本的话应该是在225行</span><br></pre></td></tr></table></figure>

<p>打开文件后，我们找到以下内容：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">if</span> (setuid(<span class="number">0</span>) != <span class="number">-1</span>) &#123;</span><br><span class="line">    DIE(<span class="string">&quot;icky Linux kernel bug!&quot;</span>);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>将其修改为：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">if</span> 0</span></span><br><span class="line">        <span class="keyword">if</span> (setuid(<span class="number">0</span>) != <span class="number">-1</span>) &#123;</span><br><span class="line">            DIE(<span class="string">&quot;icky Linux kernel bug!&quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line"><span class="meta">#<span class="keyword">endif</span></span></span><br></pre></td></tr></table></figure>

<h3 id="2-3-log-c"><a href="#2-3-log-c" class="headerlink" title="2.3 log.c "></a><font size=3>2.3 log.c </font></h3><p> boa 启动时，即便已经设置了对的 log 文件和路径，也创建了 error_log 和 access_log 文件，但是依然可能出现：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">log.c:73 unable to dup2 the error log: Bad file descriptor</span><br></pre></td></tr></table></figure>

<p>这个时候我们可以修改源码文件：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vim ~/6temp/boa-0.94.13/src/log.c +73     # 这个版本的话应该是在225行</span><br></pre></td></tr></table></figure>

<p>我们找到以下语句：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/* redirect stderr to error_log */</span></span><br><span class="line"><span class="keyword">if</span> (dup2(error_log, STDERR_FILENO) == <span class="number">-1</span>) &#123;</span><br><span class="line">    DIE(<span class="string">&quot;unable to dup2 the error log&quot;</span>);</span><br><span class="line">&#125;</span><br><span class="line">close(error_log);</span><br></pre></td></tr></table></figure>

<p>将其注释掉：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">if</span> 0</span></span><br><span class="line">        <span class="comment">/* redirect stderr to error_log */</span></span><br><span class="line">        <span class="keyword">if</span> (dup2(error_log, STDERR_FILENO) == <span class="number">-1</span>) &#123;</span><br><span class="line">            DIE(<span class="string">&quot;unable to dup2 the error log&quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        close(error_log);</span><br><span class="line"><span class="meta">#<span class="keyword">endif</span></span></span><br></pre></td></tr></table></figure>

<p> dup2 函数是用于复制文件描述符。</p>
<h2 id="3-编译源码"><a href="#3-编译源码" class="headerlink" title="3. 编译源码"></a><font size=3>3. 编译源码</font></h2><h3 id="3-1-编译命令"><a href="#3-1-编译命令" class="headerlink" title="3.1 编译命令"></a><font size=3>3.1 编译命令</font></h3><p>我们直接在 boa 源码顶层目录的 src 目录下执行 make 指令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">make</span><br></pre></td></tr></table></figure>

<p>首次进行移植的时候可能会报很多的问题，期间会报一些警告，这些警告目前好像问题不大，主要报的 error 问题及解决方法可以看后边。</p>
<h3 id="3-2-问题一"><a href="#3-2-问题一" class="headerlink" title="3.2 问题一"></a><font size=3>3.2 问题一</font></h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">yacc  -d boa_grammar.y</span><br><span class="line">make: yacc：命令未找到</span><br><span class="line">Makefile:59: recipe for target &#x27;y.tab.c&#x27; failed</span><br><span class="line">make: *** [y.tab.c] Error 127</span><br></pre></td></tr></table></figure>

<p>解决方法就是安装 bison ：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get install bison</span><br><span class="line">make clean                 # 清空之前编译的文件</span><br><span class="line">make                       # 重新编译</span><br></pre></td></tr></table></figure>

<h3 id="3-3-问题二"><a href="#3-3-问题二" class="headerlink" title="3.3 问题二"></a><font size=3>3.3 问题二</font></h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">yacc  -d boa_grammar.y</span><br><span class="line">gcc  -g -O2 -pipe -Wall -I.   -c -o y.tab.o y.tab.c</span><br><span class="line">y.tab.c: In function ‘yyparse’:</span><br><span class="line">y.tab.c:1191:16: warning: implicit declaration of function ‘yylex’ [-Wimplicit-function-declaration]</span><br><span class="line">       yychar = yylex ();</span><br><span class="line">                ^</span><br><span class="line">lex  boa_lexer.l</span><br><span class="line">make: lex：命令未找到</span><br><span class="line">Makefile:62: recipe for target &#x27;lex.yy.c&#x27; failed</span><br><span class="line">make: *** [lex.yy.c] Error 127</span><br></pre></td></tr></table></figure>

<p>解决方法就是安装 flex ：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get install flex</span><br><span class="line">make clean                 # 清空之前编译的文件</span><br><span class="line">make                       # 重新编译</span><br></pre></td></tr></table></figure>

<details class="folding-tag" blue><summary> 点击查看安装 flex 可能出现的问题 </summary>
              <div class='content'>
              <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">WARNING: The following packages cannot be authenticated!</span><br><span class="line">libfl-dev flex</span><br><span class="line">Install these packages without verification? [y/N] </span><br><span class="line">E: Some packages could not be authenticated</span><br></pre></td></tr></table></figure><p>我们可以尝试在命令后边加上一个 -f 参数，让其在安装的时候自动搜索依赖：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo  apt-get install flex -f</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h3 id="3-4-问题三"><a href="#3-4-问题三" class="headerlink" title="3.4 问题三"></a><font size=3>3.4 问题三</font></h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">gcc  -g -O2 -pipe -Wall -I.   -c -o util.o util.c</span><br><span class="line">In file included from boa.h:50:0,</span><br><span class="line">                 from util.c:26:</span><br><span class="line">util.c: In function ‘get_commonlog_time’:</span><br><span class="line">util.c:100:39: error: pasting &quot;t&quot; and &quot;-&gt;&quot; does not give a valid preprocessing token</span><br><span class="line">         time_offset = TIMEZONE_OFFSET(t);</span><br><span class="line">                                       ^</span><br><span class="line">compat.h:120:30: note: in definition of macro ‘TIMEZONE_OFFSET’</span><br><span class="line"><span class="meta prompt_"> #</span><span class="language-bash">define TIMEZONE_OFFSET(foo) foo<span class="comment">##-&gt;tm_gmtoff</span></span></span><br><span class="line">                              ^</span><br><span class="line">&lt;builtin&gt;: recipe for target &#x27;util.o&#x27; failed</span><br></pre></td></tr></table></figure>

<p>解决方法如下：</p>
<ul>
<li>修改 compat.h 文件</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">文件路径：boa-0.94.13/src/compat.h</span></span><br><span class="line">vim compat.h +120     # 这个版本的话应该是在120行</span><br></pre></td></tr></table></figure>

<p>打开文件后，我们找到以下内容：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">define</span> TIMEZONE_OFFSET(foo) foo##-&gt;tm_gmtoff</span></span><br></pre></td></tr></table></figure>

<p>将其修改为：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">define</span> TIMEZONE_OFFSET(foo) (foo)-&gt;tm_gmtoff</span></span><br></pre></td></tr></table></figure>

<h2 id="4-安装-BOA"><a href="#4-安装-BOA" class="headerlink" title="4. 安装 BOA "></a><font size=3>4. 安装 BOA </font></h2><p>后来发现这里其实直接创建到 &#x2F; 根目录下的话，会很方便后边往开发板中一移植，但是这里创建在其他目录的话，后边替换一下到根目录其实就可以了。</p>
<h3 id="4-1-创建相关目录"><a href="#4-1-创建相关目录" class="headerlink" title="4.1 创建相关目录"></a><font size=3>4.1 创建相关目录</font></h3><p>接下来就是创建安装的目录了：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">cd ~/6temp/</span><br><span class="line">mkdir -p boa boa/www boa/cgi-bin boa/log</span><br><span class="line">cd ~/6temp/boa</span><br></pre></td></tr></table></figure>

<h3 id="4-2-复制相关文件"><a href="#4-2-复制相关文件" class="headerlink" title="4.2 复制相关文件"></a><font size=3>4.2 复制相关文件</font></h3><p>（1）将 boa-0.94.13&#x2F;src 目录下生成的 boa 、 boa_indexer 二进制文件复制到 boa 目录下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cp ~/6temp/boa-0.94.13/src/boa .</span><br><span class="line">cp ~/6temp/boa-0.94.13/src/boa_indexer .</span><br></pre></td></tr></table></figure>

<p>（2）将 boa-0.94.13 目录下的 boa.conf 文件复制到 boa 下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cp ~/6temp/boa-0.94.13/boa.conf .</span><br></pre></td></tr></table></figure>

<p>（3）将 &#x2F;etc&#x2F;mime.types （ Ubuntu 根目录中的文件）复制到 boa 目录下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo cp /etc/mime.types .</span><br></pre></td></tr></table></figure>

<p> mime.types 文件用来指明不同文件扩展名对应的 MIME 类型，一般可以直接从 Linux 主机上拷贝一个，大部分也都是在主机的 &#x2F;etc 目录下，同样，将主机的 mime.types 文件拷贝到开发板上的 &#x2F;etc 目录下。</p>
<h3 id="4-3-文件“瘦身”"><a href="#4-3-文件“瘦身”" class="headerlink" title="4.3 文件“瘦身”"></a><font size=3>4.3 文件“瘦身”</font></h3><p>我们可以执行以下命令来删除 boa 可执行文件中的调试信息，只是减小文件大小，可有可无：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">strip boa</span><br></pre></td></tr></table></figure>

<h2 id="5-修改配置文件"><a href="#5-修改配置文件" class="headerlink" title="5. 修改配置文件"></a><font size=3>5. 修改配置文件</font></h2><p>我们回到 boa 的安装目录下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cd ~/6temp/boa/</span><br></pre></td></tr></table></figure>

<p>然后打开 boa.conf 文件：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vim boa.conf</span><br></pre></td></tr></table></figure>

<p>接下来就是重新指定一些文件的生成路径，因为重新指定这些路径后会帮助我们深刻的理解关于 boa 服务器的工作机制。</p>
<h3 id="5-1-修改内容"><a href="#5-1-修改内容" class="headerlink" title="5.1 修改内容"></a><font size=3>5.1 修改内容</font></h3><h4 id="5-1-1-Port"><a href="#5-1-1-Port" class="headerlink" title="5.1.1 Port "></a><font size=3>5.1.1 Port </font></h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Port 80</span><br></pre></td></tr></table></figure>

<p>端口保持默认即可。</p>
<h4 id="5-1-2-User-和-Group"><a href="#5-1-2-User-和-Group" class="headerlink" title="5.1.2 User 和 Group "></a><font size=3>5.1.2 User 和 Group </font></h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">User nobody</span><br><span class="line">Group nogroup</span><br></pre></td></tr></table></figure>

<p>将以上两句改为：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">User 0</span><br><span class="line">Group 0</span><br></pre></td></tr></table></figure>

<h4 id="5-1-3-ErrorLog-和-AccessLog"><a href="#5-1-3-ErrorLog-和-AccessLog" class="headerlink" title="5.1.3 ErrorLog 和 AccessLog "></a><font size=3>5.1.3 ErrorLog 和 AccessLog </font></h4><p> error_log 和 access_log 会自动生成，只要指定生成路径就可以了。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">ErrorLog /var/log/boa/error_log</span><br><span class="line">AccessLog /var/log/boa/access_log</span><br></pre></td></tr></table></figure>

<p>将以上两句路径修改为：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">ErrorLog /home/hk/6temp/boa/log/error_log</span><br><span class="line">AccessLog /home/hk/6temp/boa/log/access_log</span><br></pre></td></tr></table></figure>

<h4 id="5-1-4-DocumentRoot"><a href="#5-1-4-DocumentRoot" class="headerlink" title="5.1.4 DocumentRoot "></a><font size=3>5.1.4 DocumentRoot </font></h4><p>存放 HTML 文件的根路径</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">DocumentRoot /var/www</span><br></pre></td></tr></table></figure>

<p>将路径修改为：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">DocumentRoot /home/hk/6temp/boa/www</span><br></pre></td></tr></table></figure>

<h4 id="5-1-5-DirectoryIndex"><a href="#5-1-5-DirectoryIndex" class="headerlink" title="5.1.5 DirectoryIndex "></a><font size=3>5.1.5 DirectoryIndex </font></h4><p>若在浏览器地址栏输入<a target="_blank" rel="noopener" href="http://127.0.0.1/">http://127.0.0.1/</a>，则会自动返回给浏览器默认页面 index.html </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">DirectoryIndex index.html                # 保持默认</span><br></pre></td></tr></table></figure>

<p>保持默认即可。</p>
<h4 id="5-1-6-DirectoryMaker"><a href="#5-1-6-DirectoryMaker" class="headerlink" title="5.1.6 DirectoryMaker "></a><font size=3>5.1.6 DirectoryMaker </font></h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">DirectoryMaker /usr/lib/boa/boa_indexer</span><br></pre></td></tr></table></figure>

<p>修改为</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">DirectoryMaker /home/hk/6temp/boa/boa_indexer</span><br></pre></td></tr></table></figure>

<h4 id="5-1-7-MimeTypes"><a href="#5-1-7-MimeTypes" class="headerlink" title="5.1.7 MimeTypes "></a><font size=3>5.1.7 MimeTypes </font></h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">MimeTypes /etc/mime.types</span><br></pre></td></tr></table></figure>

<p>修改为</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">MimeTypes /home/hk/6temp/boa/mime.types</span><br></pre></td></tr></table></figure>

<h4 id="5-1-8-CGIPath"><a href="#5-1-8-CGIPath" class="headerlink" title="5.1.8 CGIPath "></a><font size=3>5.1.8 CGIPath </font></h4><p>指定传给 cgi 程序的 PATH 环境变量</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">CGIPath /bin:/usr/bin:/usr/local/bin</span><br></pre></td></tr></table></figure>

<p>保持默认。</p>
<h4 id="5-1-9-ScriptAlias"><a href="#5-1-9-ScriptAlias" class="headerlink" title="5.1.9 ScriptAlias "></a><font size=3>5.1.9 ScriptAlias </font></h4><p>如果输入<a target="_blank" rel="noopener" href="http://127.0.0.1/cgi-bin/test.cgi">http://127.0.0.1/cgi-bin/test.cgi</a>, 则 boa 服务器会到 &#x2F;usr&#x2F;lib&#x2F;cgi-bin&#x2F; 中寻找 test.cgi 程序。 </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/</span><br></pre></td></tr></table></figure>

<p>修改为</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ScriptAlias /cgi-bin/ /home/hk/6temp/boa/cgi-bin/</span><br></pre></td></tr></table></figure>

<h3 id="5-2-最终文件内容"><a href="#5-2-最终文件内容" class="headerlink" title="5.2 最终文件内容"></a><font size=3>5.2 最终文件内容</font></h3><details class="folding-tag" blue><summary> 点击查看详情 </summary>
              <div class='content'>
              <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Boa v0.94 configuration file</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">File format has not changed from 0.93</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">File format has changed little from 0.92</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">version changes are noted <span class="keyword">in</span> the comments</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"></span></span><br><span class="line"><span class="language-bash"><span class="comment"># The Boa configuration file is parsed with a lex/yacc or flex/bison</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">generated parser.  If it reports an error, the line number will be</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">provided; it should be easy to spot.  The syntax of each of these</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">rules is very simple, and they can occur <span class="keyword">in</span> any order.  Where possible</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">these directives mimic those of NCSA httpd 1.3; I saw no reason to</span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">introduce gratuitous differences.</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="variable">$Id</span>: boa.conf,v 1.25 2002/03/22 04:33:09 jnelson Exp $</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">The <span class="string">&quot;ServerRoot&quot;</span> is not <span class="keyword">in</span> this configuration file.  It can be compiled</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">into the server (see defines.h) or specified on the <span class="built_in">command</span> line with</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">the -c option, <span class="keyword">for</span> example:</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"></span></span><br><span class="line"><span class="language-bash"><span class="comment"># boa -c /usr/local/boa</span></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Port: The port Boa runs on.  The default port <span class="keyword">for</span> http servers is 80.</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">If it is less than 1024, the server must be started as root.</span></span><br><span class="line"></span><br><span class="line">Port 80</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Listen: the Internet address to <span class="built_in">bind</span>(2) to.  If you leave it out,</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">it takes the behavior before 0.93.17.2, <span class="built_in">which</span> is to <span class="built_in">bind</span> to all</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">addresses (INADDR_ANY).  You only get one <span class="string">&quot;Listen&quot;</span> directive,</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="keyword">if</span> you want service on multiple IP addresses, you have three choices:</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">   1. Run boa without a <span class="string">&quot;Listen&quot;</span> directive</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">      a. All addresses are treated the same; makes sense <span class="keyword">if</span> the addresses</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">         are localhost, ppp, and eth0.</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">      b. Use the VirtualHost directive below to point requests to different</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">         files.  Should be good <span class="keyword">for</span> a very large number of addresses (web</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">         hosting clients).</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">   2. Run one copy of boa per IP address, each has its own configuration</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">      with a <span class="string">&quot;Listen&quot;</span> directive.  No big deal up to a few tens of addresses.</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">      Nice separation between clients.</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">The name you provide gets run through inet_aton(3), so you have to use dotted</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">quad notation.  This configuration is too important to trust some DNS.</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">Listen 192.68.0.5</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"> User: The name or UID the server should run as.</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Group: The group name or GID the server should run as.</span></span><br><span class="line"></span><br><span class="line">User 0 </span><br><span class="line">Group 0</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">ServerAdmin: The email address <span class="built_in">where</span> server problems should be sent.</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Note: this is not currently used, except as an environment variable</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="keyword">for</span> CGIs.</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">ServerAdmin root@localhost</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">ErrorLog: The location of the error <span class="built_in">log</span> file. If this does not start</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">with /, it is considered relative to the server root.</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Set to /dev/null <span class="keyword">if</span> you don<span class="string">&#x27;t want errors logged.</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">If unset, defaults to /dev/stderr</span></span></span><br><span class="line"></span><br><span class="line">ErrorLog /home/hk/6temp/boa/log/error_log</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">Please NOTE: Sending the logs to a pipe (&#x27;</span>|<span class="string">&#x27;), as shown below,</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string"> is somewhat experimental and might fail under heavy load.</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">&quot;Usual libc implementations of printf will stall the whole</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string"> process if the receiving end of a pipe stops reading.&quot;</span></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="string">ErrorLog &quot;|/usr/sbin/cronolog --symlink=/var/log/boa/error_log /var/log/boa/error-%Y%m%d.log&quot;</span></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">AccessLog: The location of the access log file. If this does not</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">start with /, it is considered relative to the server root.</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">Comment out or set to /dev/null (less effective) to disable</span></span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">Access logging.</span></span></span><br><span class="line"></span><br><span class="line">AccessLog /home/hk/6temp/boa/log/access_log</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">Please NOTE: Sending the logs to a pipe (&#x27;</span>|<span class="string">&#x27;), as shown below,</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string"> is somewhat experimental and might fail under heavy load.</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">&quot;Usual libc implementations of printf will stall the whole</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string"> process if the receiving end of a pipe stops reading.&quot;</span></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="string">AccessLog  &quot;|/usr/sbin/cronolog --symlink=/var/log/boa/access_log /var/log/boa/access-%Y%m%d.log&quot;</span></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">UseLocaltime: Logical switch.  Uncomment to use localtime</span></span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">instead of UTC time</span></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="string">UseLocaltime</span></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">VerboseCGILogs: this is just a logical switch.</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string"> It simply notes the start and stop times of cgis in the error log</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">Comment out to disable.</span></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="string">VerboseCGILogs</span></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">ServerName: the name of this server that should be sent back to</span></span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">clients if different than that returned by gethostname + gethostbyname</span></span> </span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="string">ServerName www.your.org.here</span></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">VirtualHost: a logical switch.</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">Comment out to disable.</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">Given DocumentRoot /var/www, requests on interface &#x27;</span>A<span class="string">&#x27; or IP &#x27;</span>IP-A<span class="string">&#x27;</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">become /var/www/IP-A.</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">Example: http://localhost/ becomes /var/www/127.0.0.1</span></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="string"></span></span></span><br><span class="line"><span class="string"><span class="language-bash"># Not used until version 0.93.17.2.  This &quot;feature&quot; also breaks commonlog</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">output rules, it prepends the interface number to each access_log line.</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">You are expected to fix that problem with a postprocessing script.</span></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="string">VirtualHost</span></span> </span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">DocumentRoot: The root directory of the HTML documents.</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">Comment out to disable server non user files.</span></span></span><br><span class="line"></span><br><span class="line">DocumentRoot /home/hk/6temp/boa/www</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">UserDir: The name of the directory which is appended onto a user&#x27;</span>s home</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">directory <span class="keyword">if</span> a ~user request is recieved.</span></span><br><span class="line"></span><br><span class="line">UserDir public_html</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">DirectoryIndex: Name of the file to use as a pre-written HTML</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">directory index.  Please MAKE AND USE THESE FILES.  On the</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">fly creation of directory indexes can be _slow_.</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Comment out to always use DirectoryMaker</span></span><br><span class="line"></span><br><span class="line">DirectoryIndex index.html</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">DirectoryMaker: Name of program used to create a directory listing.</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Comment out to <span class="built_in">disable</span> directory listings.  If both this and</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">DirectoryIndex are commented out, accessing a directory will give</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">an error (though accessing files <span class="keyword">in</span> the directory are still ok).</span></span><br><span class="line"></span><br><span class="line">DirectoryMaker /home/hk/6temp/boa/boa_indexer</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">DirectoryCache: If DirectoryIndex doesn<span class="string">&#x27;t exist, and DirectoryMaker</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">has been commented out, the the on-the-fly indexing of Boa can be used</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">to generate indexes of directories. Be warned that the output is</span></span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">extremely minimal and can cause delays when slow disks are used.</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">Note: The DirectoryCache must be writable by the same user/group that</span></span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">Boa runs as.</span></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">DirectoryCache /var/spool/boa/dircache</span></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">KeepAliveMax: Number of KeepAlive requests to allow per connection</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">Comment out, or set to 0 to disable keepalive processing</span></span></span><br><span class="line"></span><br><span class="line">KeepAliveMax 1000</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">KeepAliveTimeout: seconds to wait before keepalive connection times out</span></span></span><br><span class="line"></span><br><span class="line">KeepAliveTimeout 10</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">MimeTypes: This is the file that is used to generate mime type pairs</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">and Content-Type fields for boa.</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">Set to /dev/null if you do not want to load a mime types file.</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">Do *not* comment out (better use AddType!)</span></span></span><br><span class="line"></span><br><span class="line">MimeTypes /home/hk/6temp/boa/mime.types</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">DefaultType: MIME type used if the file extension is unknown, or there</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">is no file extension.</span></span></span><br><span class="line"></span><br><span class="line">DefaultType text/plain</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">CGIPath: The value of the $PATH environment variable given to CGI progs.</span></span></span><br><span class="line"></span><br><span class="line">CGIPath /bin:/usr/bin:/usr/local/bin</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">SinglePostLimit: The maximum allowable number of bytes in</span></span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">a single POST.  Default is normally 1MB.</span></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">AddType: adds types without editing mime.types</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">Example: AddType type extension [extension ...]</span></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">Uncomment the next line if you want .cgi files to execute from anywhere</span></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="string">AddType application/x-httpd-cgi cgi</span></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">Redirect, Alias, and ScriptAlias all have the same semantics -- they</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">match the beginning of a request and take appropriate action.  Use</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">Redirect for other servers, Alias for the same server, and ScriptAlias</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">to enable directories for script execution.</span></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">Redirect allows you to tell clients about documents which used to exist in</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">your server&#x27;</span>s namespace, but <span class="keyword">do</span> not anymore. This allows you to tell the</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">clients <span class="built_in">where</span> to look <span class="keyword">for</span> the relocated document.</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Example: Redirect /bar http://elsewhere/feh/bar</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Aliases: Aliases one path to another.</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Example: Alias /path1/bar /path2/foo</span></span><br><span class="line"></span><br><span class="line">Alias /doc /usr/doc</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">ScriptAlias: Maps a virtual path to a directory <span class="keyword">for</span> serving scripts</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Example: ScriptAlias /htbin/ /www/htbin/</span></span><br><span class="line"></span><br><span class="line">ScriptAlias /cgi-bin/ /home/hk/6temp/boa/cgi-bin/</span><br><span class="line"></span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h2 id="6-测试文件添加"><a href="#6-测试文件添加" class="headerlink" title="6. 测试文件添加"></a><font size=3>6. 测试文件添加</font></h2><h3 id="6-1-index-html"><a href="#6-1-index-html" class="headerlink" title="6.1 index.html "></a><font size=3>6.1 index.html </font></h3><p>我们在 boa 的安装目录下的子目录 www 中，也就是 boa&#x2F;www 目录中新建 index.html 文件，并输入以下内容：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">html</span>&gt;</span>  </span><br><span class="line">	<span class="tag">&lt;<span class="name">body</span>&gt;</span>  </span><br><span class="line">		<span class="tag">&lt;<span class="name">h3</span>&gt;</span>this is a test!<span class="tag">&lt;/<span class="name">h3</span>&gt;</span><span class="tag">&lt;<span class="name">br</span>/&gt;</span>  </span><br><span class="line">		<span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">&quot;image.jpg&quot;</span>/&gt;</span>  </span><br><span class="line">		<span class="tag">&lt;<span class="name">h3</span>&gt;</span>tree picture<span class="tag">&lt;/<span class="name">h3</span>&gt;</span><span class="tag">&lt;<span class="name">br</span>/&gt;</span>  </span><br><span class="line">        <span class="comment">&lt;!-- 指定了cgi可执行文件存放的路径，默认从/boa的根目录开始查找 --&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;/cgi-bin/test.cgi&quot;</span>&gt;</span>to cgi page<span class="tag">&lt;/<span class="name">a</span>&gt;</span>    </span><br><span class="line">	<span class="tag">&lt;/<span class="name">body</span>&gt;</span>  </span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span> </span><br></pre></td></tr></table></figure>

<p>最后保存为 utf-8 格式。</p>
<h3 id="6-2-image-jpg"><a href="#6-2-image-jpg" class="headerlink" title="6.2 image.jpg "></a><font size=3>6.2 image.jpg </font></h3><p>准备一张图片放在 ~&#x2F;6temp&#x2F;boa 目录下，用于图片显示测试。</p>
<h3 id="6-3-test-c"><a href="#6-3-test-c" class="headerlink" title="6.3 test.c "></a><font size=3>6.3 test.c </font></h3><p>在 ~&#x2F;6temp&#x2F;boa&#x2F;www 目录下新建 test.c 测试文件，文件内容如下：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;stdio.h&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="type">int</span> <span class="title function_">main</span><span class="params">(<span class="type">int</span> argc, <span class="type">const</span> <span class="type">char</span> *argv[])</span></span><br><span class="line">&#123;</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;Content-type:text/html\n\n&quot;</span>); <span class="comment">/* 这句一定要加上 */</span></span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;&lt;html&gt;&lt;body&gt;&quot;</span>);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;&lt;font style=\&quot;color:red; font-size:30px;\&quot;&gt;Hello, CGI!&lt;/font&gt;&lt;br/&gt;&quot;</span>);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;&lt;a href=\&quot;/index.html\&quot;&gt;return index.html&lt;/a&gt;&quot;</span>);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;&lt;/body&gt;&lt;/html&gt;&quot;</span>);</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>然后我们使用 gcc 编译器将其编译为 .cgi 为后缀的可执行文件：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">gcc test.c -o test.cgi -Wall</span><br></pre></td></tr></table></figure>

<p>然后我们便会得到一个 test.cgi 可执行文件，我们将其拷贝到 ~&#x2F;6temp&#x2F;boa&#x2F;cgi-bin 目录下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cp ~/6temp/boa/www/test.cgi ~/6temp/boa/cgi-bin/</span><br></pre></td></tr></table></figure>

<h3 id="6-4-access-log-与-error-log"><a href="#6-4-access-log-与-error-log" class="headerlink" title="6.4 access_log 与 error_log "></a><font size=3>6.4 access_log 与 error_log </font></h3><p>首次运行前，我们在 ~&#x2F;6temp&#x2F;boa&#x2F;log 目录下新建 access_log 文件和 error_log 文件：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">touch ~/6temp/boa/log/access_log</span><br><span class="line">touch ~/6temp/boa/log/error_log</span><br></pre></td></tr></table></figure>

<p>不创建的话可能在启动 boa 的时候会报以下错误：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">log.c:73 - unable to dup2 the error log: Bad file descriptor</span><br></pre></td></tr></table></figure>

<h2 id="7-文件组成"><a href="#7-文件组成" class="headerlink" title="7. 文件组成"></a><font size=3>7. 文件组成</font></h2><p>移植安装完成后，我们看一下这个 boa 目录的组成：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd ~/6temp/boa</span><br><span class="line">tree</span><br></pre></td></tr></table></figure>

<p>然后我们可以看到目录结构如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">.</span><br><span class="line">├── boa</span><br><span class="line">├── boa.conf</span><br><span class="line">├── boa_indexer</span><br><span class="line">├── cgi-bin</span><br><span class="line">│   └── test.cgi</span><br><span class="line">├── log</span><br><span class="line">│   ├── access_log</span><br><span class="line">│   └── error_log</span><br><span class="line">├── mime.types</span><br><span class="line">└── www</span><br><span class="line">    ├── image.jpg</span><br><span class="line">    ├── index.html</span><br><span class="line">    ├── test.c</span><br><span class="line">    └── test.cgi</span><br><span class="line"></span><br><span class="line">3 directories, 11 files</span><br></pre></td></tr></table></figure>

<h2 id="8-效果测试"><a href="#8-效果测试" class="headerlink" title="8. 效果测试"></a><font size=3>8. 效果测试</font></h2><h3 id="8-1-启动-boa"><a href="#8-1-启动-boa" class="headerlink" title="8.1 启动 boa "></a><font size=3>8.1 启动 boa </font></h3><p>我们在 ~&#x2F;6temp&#x2F;boa 目录下执行以下命令即可启动 boa 服务器：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd ~/6temp/boa</span><br><span class="line">sudo ./boa</span><br></pre></td></tr></table></figure>

<details class="folding-tag" blue><summary> 点击查看可能出现的问题 </summary>
              <div class='content'>
              <ul><li>问题一</li></ul><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Could not chdir to &quot;/etc/boa&quot;: aborting</span><br></pre></td></tr></table></figure><p>解决方法看 BOA 移植到 Ubuntu 这部分的 2.1 节。</p><ul><li>问题二</li></ul><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">boa.c:226 - icky linux kernel bug!: No suchfile or directory</span><br></pre></td></tr></table></figure><p>解决方法看 BOA 移植到 Ubuntu 这部分的 2.2 节。</p><ul><li>问题三</li></ul><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[05/Sep/2022:01:40:11 +0000] log.c:73 - unable to dup2 the error log: Bad file descriptor</span><br></pre></td></tr></table></figure><p>解决方法看 BOA 移植到 Ubuntu 这部分的 6.4 节。</p><ul><li>问题四</li></ul><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[05/Sep/2022:02:13:47 +0000] boa.c:194 - unable to bind: Address already in use</span><br></pre></td></tr></table></figure><p>原因就是之前已经启动过 boa 服务器，解决办法就是杀掉这个进程：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">ps -axj  | grep boa # 查看进程PID</span><br><span class="line">sudo kill -9 PID    # 杀掉整个进程</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<p>启动成功则会有以下提示信息：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">[05/Sep/2022:02:16:04 +0000] boa: server version Boa/0.94.13</span><br><span class="line">[05/Sep/2022:02:16:04 +0000] boa: server built Sep  5 2022 at 10:04:15.</span><br><span class="line">[05/Sep/2022:02:16:04 +0000] boa: starting server pid=119253, port 80</span><br></pre></td></tr></table></figure>

<p>然后整个进程就运行在后台了。</p>
<h3 id="8-2-本地测试"><a href="#8-2-本地测试" class="headerlink" title="8.2 本地测试"></a><font size=3>8.2 本地测试</font></h3><p>我们打开 Ubuntu 的浏览器，然后输入:</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">http://127.0.0.1</span><br><span class="line"></span><br><span class="line"># 或者 http://localhostip:port 即</span><br><span class="line">http://192.168.10.101:80 </span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>然后便会弹出这样一个页面：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV11-%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%93/LV11-01-BOA%E6%9C%8D%E5%8A%A1%E5%99%A8-01-%E7%A7%BB%E6%A4%8D%E8%BF%87%E7%A8%8B/img/image-20220905101822394.png" alt="image-20220905101822394" style="zoom:50%;" />

<p>这就说明我们的 boa 服务器已经在正常运行了，我们再点击 return ro cgi page 会跳转到这样一个页面：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV11-%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%93/LV11-01-BOA%E6%9C%8D%E5%8A%A1%E5%99%A8-01-%E7%A7%BB%E6%A4%8D%E8%BF%87%E7%A8%8B/img/image-20220905101918395.png" alt="image-20220905101918395" style="zoom:50%;" />

<p>这便说明我们的 boa 服务器已经可以正常在 Ubuntu 上运行了。</p>
<h1 id="四、-BOA-移植到开发板"><a href="#四、-BOA-移植到开发板" class="headerlink" title="四、 BOA 移植到开发板"></a><font size=3>四、 BOA 移植到开发板</font></h1><h2 id="1-移植过程"><a href="#1-移植过程" class="headerlink" title="1. 移植过程"></a><font size=3>1. 移植过程</font></h2><p>其实移植到开发板上的步骤与移植到 Ubuntu 的步骤是一模一样的，只是需要修改一下执行完 .configure 后生成的 makefile 文件，我们找到以下语句：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">CC = gcc </span><br><span class="line">CPP = gcc -E</span><br></pre></td></tr></table></figure>

<p>将其修改为：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">CC = arm-linux-gcc</span><br><span class="line">CPP = arm-linux-gcc -E</span><br></pre></td></tr></table></figure>

<p>然后重新编译生成相关文件，其他的步骤就和移植到 ubuntu 步骤一样了，另外要</p>
<p>【注意】</p>
<p>（1）在编译 test.c 的时候也需要换成交叉编译器。</p>
<p>（2）拷贝 mime.types 的时候也是拷贝主机下的，开发板的文件系统应该没有这文件。</p>
<h2 id="2-启动问题"><a href="#2-启动问题" class="headerlink" title="2. 启动问题"></a><font size=3>2. 启动问题</font></h2><h3 id="2-1-问题一"><a href="#2-1-问题一" class="headerlink" title="2.1 问题一"></a><font size=3>2.1 问题一</font></h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">[root@farsightboa]#</span><span class="language-bash">./boa</span></span><br><span class="line">[01/Jan/1970:00:20:49 +0000] boa.c:211 - getpwuid: No such file or directory</span><br></pre></td></tr></table></figure>

<p>【解决方法】修改 ~&#x2F;6temp&#x2F;boa-0.94.13&#x2F;src&#x2F;boa.c 文件</p>
<p>找到如下语句（应该在 211 行）：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">if</span> (passwdbuf == <span class="literal">NULL</span>) &#123;</span><br><span class="line">    DIE(<span class="string">&quot;getpwuid&quot;</span>);</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">if</span> (initgroups(passwdbuf-&gt;pw_name, passwdbuf-&gt;pw_gid) == <span class="number">-1</span>) &#123;</span><br><span class="line">    DIE(<span class="string">&quot;initgroups&quot;</span>);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>将其注释掉：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">if</span> 0</span></span><br><span class="line">        <span class="keyword">if</span> (passwdbuf == <span class="literal">NULL</span>) &#123;</span><br><span class="line">            DIE(<span class="string">&quot;getpwuid&quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span> (initgroups(passwdbuf-&gt;pw_name, passwdbuf-&gt;pw_gid) == <span class="number">-1</span>) &#123;</span><br><span class="line">            DIE(<span class="string">&quot;initgroups&quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line"><span class="meta">#endi</span></span><br></pre></td></tr></table></figure>

<h3 id="2-2-问题二"><a href="#2-2-问题二" class="headerlink" title="2.2 问题二"></a><font size=3>2.2 问题二</font></h3><p>在启动的时候有以下提示，然后程序直接退出了：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">gethostbyname:: Success</span><br></pre></td></tr></table></figure>

<p>【解决方法】</p>
<p>在开发板中 &#x2F;boa 目录下打开 boa.conf 文件，添加如下语句：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ServerName  www.your.org.here</span><br></pre></td></tr></table></figure>

<h2 id="3-主机访问"><a href="#3-主机访问" class="headerlink" title="3. 主机访问"></a><font size=3>3. 主机访问</font></h2><p>开发板中没有图形界面，也没有浏览器，我们可以借助主机来进行，我们的主机 ubuntu 需要能与开发板 ping 通，然后在浏览器地址栏输入：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">http://&lt;开发板ip&gt;:port</span><br><span class="line"></span><br><span class="line">或者直接输入：</span><br><span class="line">&lt;开发板ip&gt;:port </span><br></pre></td></tr></table></figure>

<h1 id="五、-boa-conf-文件详解"><a href="#五、-boa-conf-文件详解" class="headerlink" title="五、 boa.conf 文件详解"></a><font size=3>五、 boa.conf 文件详解</font></h1><h2 id="1-Port"><a href="#1-Port" class="headerlink" title="1. Port "></a><font size=3>1. Port </font></h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Port 80</span><br></pre></td></tr></table></figure>

<p>监听的端口号，缺省都是 80 ，一般无需修改。注意，如果我们的 httpd 服务器已经开启，那么必须关掉或者重新设定端口号，当修改了模式 http 端口，那么访问的时候要加上端口号，如： <a href="http://localhostip:port">http://localhostip:port</a> 。</p>
<h2 id="2-User"><a href="#2-User" class="headerlink" title="2. User "></a><font size=3>2. User </font></h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">User nobody</span><br></pre></td></tr></table></figure>

<p>作为哪个用户运行，即它拥有该用户的权限，一般都是 nobody ，需要  &#x2F;etc&#x2F;passwd 中有 nobody 用户。</p>
<h2 id="3-Group"><a href="#3-Group" class="headerlink" title="3. Group "></a><font size=3>3. Group </font></h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Group nogroup</span><br></pre></td></tr></table></figure>

<p>作为哪个用户组运行，即它拥有该用户组的权限，一般都是 nogroup ，需要在 &#x2F;etc&#x2F;group 文件中有 nogroup 组。</p>
<h2 id="4-UseLocaltime"><a href="#4-UseLocaltime" class="headerlink" title="4. UseLocaltime "></a><font size=3>4. UseLocaltime </font></h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">UseLocaltime: Logical switch.  Uncomment to use localtime</span></span><br></pre></td></tr></table></figure>

<p>是否使用本地时间。如果没有注释掉，则使用本地时间。注释掉则使用 UTC 时间。</p>
<h2 id="5-VerboseCGILogs"><a href="#5-VerboseCGILogs" class="headerlink" title="5. VerboseCGILogs "></a><font size=3>5. VerboseCGILogs </font></h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">VerboseCGILogs: this is just a logical switch.</span></span><br></pre></td></tr></table></figure>

<p>是否记录CGI运行信息，如果没有注释掉，则记录，注释掉则不记录。</p>
<h2 id="6-ServerName"><a href="#6-ServerName" class="headerlink" title="6. ServerName "></a><font size=3>6. ServerName </font></h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">ServerName www.your.org.here</span></span><br><span class="line">ServerName www.chad.com</span><br></pre></td></tr></table></figure>

<p>服务器名字。</p>
<h2 id="7-VirtualHost"><a href="#7-VirtualHost" class="headerlink" title="7. VirtualHost "></a><font size=3>7. VirtualHost </font></h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">VirtualHost: a logical switch.</span></span><br></pre></td></tr></table></figure>

<p>是否启动虚拟主机功能，即设备可以有多个网络接口，每个接口都可以拥有一个虚拟的 Web 服务器。一般注释掉，即不需要启动。</p>
<h2 id="8-DocumentRoot"><a href="#8-DocumentRoot" class="headerlink" title="8. DocumentRoot "></a><font size=3>8. DocumentRoot </font></h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">DocumentRoot /var/www</span><br></pre></td></tr></table></figure>

<p>非常重要， HTML 文档的主目录。如果没有以 &#x2F; 开始，则表示从服务器的根路径开始。注意，如果此处设置不正确，将不能打开网页。</p>
<h2 id="9-UserDir"><a href="#9-UserDir" class="headerlink" title="9. UserDir "></a><font size=3>9. UserDir </font></h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">UserDir public_html</span><br></pre></td></tr></table></figure>

<p>如果收到一个用户请求的话，在用户主目录后再增加的目录名。</p>
<h2 id="10-DirectoryIndex"><a href="#10-DirectoryIndex" class="headerlink" title="10. DirectoryIndex "></a><font size=3>10. DirectoryIndex </font></h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">DirectoryIndex index.html</span><br></pre></td></tr></table></figure>

<p> HTML 目录索引的文件名，也是没有用户只指明访问目录时返回的文件名。</p>
<h2 id="11-DirectoryMaker"><a href="#11-DirectoryMaker" class="headerlink" title="11. DirectoryMaker "></a><font size=3>11. DirectoryMaker </font></h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">DirectoryMaker /usr/lib/boa/boa_indexer</span><br></pre></td></tr></table></figure>

<p>当 HTML 目录没有索引文件时，用户只指明访问目录时， boa 会调用该程序生成索引文件然后返回给用户，因为该过程比较慢最好不执行，可以注释掉或者给每个 HTML 目录加上 DirectoryIndex 指明的文件。</p>
<h2 id="12-DirectoryCache"><a href="#12-DirectoryCache" class="headerlink" title="12. DirectoryCache "></a><font size=3>12. DirectoryCache </font></h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">DirectoryCache /var/spool/boa/dircache</span></span><br><span class="line">DirectoryCache /var/spool/boa/dircache</span><br></pre></td></tr></table></figure>

<p>如果 DirectoryIndex 不存在，并且 DirectoryMaker 被注释，那么就用 BOA 自带的索引生成程序来生成目录的索引文件并输出到 DirectoryCache 目录，该目录必须是 BOA 能读写。</p>
<h2 id="13-KeepAliveMax"><a href="#13-KeepAliveMax" class="headerlink" title="13. KeepAliveMax "></a><font size=3>13. KeepAliveMax </font></h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">KeepAliveMax 1000</span><br></pre></td></tr></table></figure>

<p>一个连接所允许的 HTTP 持续作用请求最大数目，注释或设为 0 都将关闭 HTTP 持续作用。</p>
<h2 id="14-KeepAliveTimeout"><a href="#14-KeepAliveTimeout" class="headerlink" title="14. KeepAliveTimeout "></a><font size=3>14. KeepAliveTimeout </font></h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">KeepAliveTimeout 10</span><br></pre></td></tr></table></figure>

<p> HTTP 持续作用中服务器在两次请求之间等待的时间数，以秒为单位，超时将关闭连接。</p>
<h2 id="15-MimeTypes"><a href="#15-MimeTypes" class="headerlink" title="15. MimeTypes "></a><font size=3>15. MimeTypes </font></h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">MimeTypes /etc/mime.types</span><br></pre></td></tr></table></figure>

<p>指明 mime.types 文件位置。如果没有以 &#x2F; 开始，则表示从服务器的根路径开始。可以注释掉避免使用 mime.types 文件，此时需要用 AddType 在本文件里指明。</p>
<h2 id="16-DefaultType"><a href="#16-DefaultType" class="headerlink" title="16. DefaultType "></a><font size=3>16. DefaultType </font></h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">DefaultType text/plain</span><br></pre></td></tr></table></figure>

<p>文件扩展名没有或未知的话，使用的缺省 MIME 类型。</p>
<h2 id="17-CGIPath"><a href="#17-CGIPath" class="headerlink" title="17. CGIPath "></a><font size=3>17. CGIPath </font></h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">CGIPath /bin:/usr/bin:/usr/local/bin</span><br></pre></td></tr></table></figure>

<p>提供 CGI 程序的 PATH 环境变量值。</p>
<h2 id="18-AddType"><a href="#18-AddType" class="headerlink" title="18. AddType "></a><font size=3>18. AddType </font></h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">AddType: adds types without editing mime.types</span></span><br><span class="line">AddType application/x-httpd-cgi cgi</span><br></pre></td></tr></table></figure>

<p>将文件扩展名和 MIME 类型关联起来，和 mime.types 文件作用一样。如果用 mime.types 文件，则注释掉，如果不使用 mime.types 文件，则必须使用。</p>
<h2 id="19-Redirect"><a href="#19-Redirect" class="headerlink" title="19. Redirect "></a><font size=3>19. Redirect </font></h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Redirect /bar http://elsewhere/feh/bar</span><br></pre></td></tr></table></figure>

<p>指明文档重定向路径。</p>
<h2 id="20-Alias"><a href="#20-Alias" class="headerlink" title="20. Alias "></a><font size=3>20. Alias </font></h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Alias /doc /usr/doc</span><br></pre></td></tr></table></figure>

<p>为路径加上别名。</p>
<h2 id="21-ScriptAlias"><a href="#21-ScriptAlias" class="headerlink" title="21. ScriptAlias "></a><font size=3>21. ScriptAlias </font></h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/</span><br></pre></td></tr></table></figure>

<p>非常重要，指明 CGI 脚本的虚拟路径对应的实际路径。一般所有的 CGI 脚本都要放在实际路径里，用户访问执行时输入站点+虚拟路径+ CGI 脚本名。</p>

    </div>

    
    
    

    <footer class="post-footer">




    <div>
        
            <div style="text-align:center;color: #ccc;font-size:14px;">
            ----------本文结束
            <i class="fas fa-fan fa-spin" style="color: #FF1493; font-size: 1rem"></i>
            感谢您的阅读----------
            </div>
        
    </div>





  
  <div class="my_post_copyright"> 
    <p><span>文章标题:</span><a href="/post/1d9989a.html">LV11-01-BOA服务器-01-移植过程</a></p>
    <p><span>文章作者:</span><a href="/" title="欢迎访问 《苏木》 的学习笔记">苏木</a></p>
    <p><span>发布时间:</span>2023年07月08日 - 19:17</p>
    <p><span>最后更新:</span>2025年06月14日 - 00:25</p>
    <p><span>原始链接:</span><a href="/post/1d9989a.html" title="LV11-01-BOA服务器-01-移植过程">https://sumumm.github.io/post/1d9989a.html</a></p>
    <p><span>许可协议:</span><i class="fab fa-creative-commons"></i> <a rel="license" href= "https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>  
  </div>
  


          <div class="post-tags">
              <a href="/tags/LV11-%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%93/" rel="tag"><i class="fa fa-tag"></i> LV11-第三方库</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/post/6ea0d6ed.html" rel="prev" title="LV11-02-CGIC库-01-移植过程">
                  <i class="fa fa-angle-left"></i> LV11-02-CGIC库-01-移植过程
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/post/c2a30307.html" rel="next" title="LV10-12-input子系统-02-开发框架">
                  LV10-12-input子系统-02-开发框架 <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 2017 – 
    <span itemprop="copyrightYear">2025</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">苏木</span>
  </div>
<div class="wordcount">
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-line"></i>
    </span>
      <span>站点总字数：</span>
    <span title="站点总字数">3.7m</span>
  </span>
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span>站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">225:26</span>
  </span>
</div>




    <span id="sitetime"></span>
    <script defer language=javascript>
        function siteTime()
        {
            window.setTimeout("siteTime()", 1000);
            var seconds = 1000;
            var minutes = seconds * 60;
            var hours = minutes * 60;
            var days = hours * 24;
            var years = days * 365;
            var today = new Date();
            var todayYear = today.getFullYear();
            var todayMonth = today.getMonth()+1;
            var todayDate = today.getDate();
            var todayHour = today.getHours();
            var todayMinute = today.getMinutes();
            var todaySecond = today.getSeconds();
            /*==================================================
            Date.UTC() -- 返回date对象距世界标准时间(UTC)1970年1月1日午夜之间的毫秒数(时间戳)
            year        - 作为date对象的年份，为4位年份值
            month       - 0-11之间的整数，做为date对象的月份
            day         - 1-31之间的整数，做为date对象的天数
            hours       - 0(午夜24点)-23之间的整数，做为date对象的小时数
            minutes     - 0-59之间的整数，做为date对象的分钟数
            seconds     - 0-59之间的整数，做为date对象的秒数
            microseconds - 0-999之间的整数，做为date对象的毫秒数
            ==================================================*/
            var t1 = Date.UTC(2017, 
                              5, 
                              19, 
                              0, 
                              0, 
                              0); //北京时间
            var t2 = Date.UTC(todayYear,todayMonth,todayDate,todayHour,todayMinute,todaySecond);
            var diff = t2-t1;
            var diffYears = Math.floor(diff/years);
            var diffDays = Math.floor((diff/days)-diffYears*365);
            var diffHours = Math.floor((diff-(diffYears*365+diffDays)*days)/hours);
            var diffMinutes = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours)/minutes);
            var diffSeconds = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours-diffMinutes*minutes)/seconds);
            document.getElementById("sitetime").innerHTML="已在这里 "+diffYears+" 年 "+diffDays+" 天 "+diffHours+" 小时 "+diffMinutes+" 分钟 "+diffSeconds+" 秒";
        }
        siteTime();
    </script>



    </div>
  </footer>

  
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/next-theme-pjax/0.6.0/pjax.min.js" integrity="sha256-vxLn1tSKWD4dqbMRyv940UYw4sXgMtYcK6reefzZrao=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.umd.js" integrity="sha256-ytMJGN3toR+a84u7g7NuHm91VIR06Q41kMWDr2pq7Zo=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/lozad.js/1.16.0/lozad.min.js" integrity="sha256-mOFREFhqmHeQbXpK2lp4nA3qooVgACfh88fpJftLBbc=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script><script src="/js/pjax.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>




  <script src="/js/third-party/fancybox.js"></script>

  <script src="/js/third-party/pace.js"></script>


  




  

  <script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>


 
        <div id="click-show-text"
            data-mobile = false
            data-text = 富强,民主,文明,和谐,自由,平等,公正,法制,爱国,敬业,诚信,友善
            data-fontsize = 15px
            data-random= false>
        </div>
       

      
        <script async src=https://cdn.jsdelivr.net/npm/hexo-next-mouse-effect@latest/click/showText.js></script>
      

      
    




    <script async src="/js/fancybox_param.js"></script>





<!-- APlayer本体 -->



</body>
</html>
